function formatTime(val) {
    var dateObj = new Date(val*1000);
    var UnixTimeToDate = dateObj.getFullYear() + '-' + addZero(dateObj.getMonth() + 1) + '-' + addZero(dateObj.getDate()) + ' ' + addZero(dateObj.getHours()) + ':' + addZero(dateObj.getMinutes()) + ':' + addZero(dateObj.getSeconds());
    document.write(UnixTimeToDate);
}

function formatDate(val) {
    var dateObj = new Date(val*1000);
    var UnixTimeToDate = dateObj.getFullYear() + '-' + addZero(dateObj.getMonth() + 1) + '-' + addZero(dateObj.getDate());
    document.write(UnixTimeToDate);
}
function addZero(i) {
    return (i < 10 ? "0" : "") + i;
}